<script lang="ts">
import Progress from "../components/TopProgress.vue"

console.log(window);
export default {
  components: {
    Progress
  },
  mounted() {
    console.log(this);
  },
};
// --call、apply、bind使用示例--
let dog = {
  name: "旺财",
  cry: function () {
    console.log(`${this.name} is crying`);
  },
  eat: function (param1: string, param2: string) {
    console.log(`${this.name} is eating ${param1},${param2}`);
  },
};
let cat = { name: "小红" };
dog.cry();
dog.cry.call(cat);
dog.eat("骨头", "小美");
dog.eat.call(cat, "鱼", "虫");
dog.eat.apply(cat, ["鱼", "虫"]);

let funnc = dog.eat.bind(cat, "鱼", "虫"); // bind返回一个新的函数，可以立即执行，也可以稍后执行
funnc();

// 定义 Animal 类,使用class语法实现继承
class Animal2 {
  name: string;
  constructor(name: string) {
    this.name = name;
  }
  eat(food: string) {
    console.log(`${this.name} is eating ${food}`);
  }
}
const cat2 = new Animal2("小x猫");
cat2.eat("10虫"); // 输出：小猫 is eating 虫
fetch("https://www.baidu.com/")
fetch("https://jsonplaceholder.typicode.com/todos/1",{}).then((response) => {
console.log(response);
})
</script>
<template>
  <h3>ATV</h3>
  <Progress/>
</template>
